//
//  MAMService.m
//  基金e讯
//
//  Created by imac on 14-2-18.
//  Copyright (c) 2014年 caibaocheng. All rights reserved.
//

#import "WebService.h"

@implementation WebService

+ (void)getPushList:(NSDictionary *)params
          WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getPsuhList"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

+ (void)getUserMsgList:(NSDictionary *)params
             WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getUserMsgList"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}


#pragma mark - News
//查询用户关注频道列表接口
+ (void)findUserMarkChannelList:(NSDictionary *)params
              WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getUserSubChanelList.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//用户创建分组接口
+ (void)createGroup:(NSDictionary *)params
                      WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"addGroup.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//分组追加频道
+ (void)addChannelToGroup:(NSDictionary *)params
          WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"addChannelToGroup.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}


//根据分组id查询频道接口
+ (void)findGroupSubChannelList:(NSDictionary *)params
                      WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getChannelByGroup.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//删除分组
+ (void)deleteGroup:(NSDictionary *)params
                      WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"deleteGroup.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//获取文章列表接口
+ (void)findArticleList:(NSDictionary *)params
          WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getArticleList.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//频道订阅
+ (void)addMarkChannel:(NSDictionary *)params
              WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"addUserSubChanel.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}
//取消订阅频道
+ (void)deleteMarkChannel:(NSDictionary *)params
             WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"cancelUserSubChanel.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//查询文章详情
+ (void)findArticleDetail:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getArticleById.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//查询文章评论列表
+ (void)findArticleCommentList:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getArticleComment"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//添加评论
+ (void)addComment:(NSDictionary *)params
                     WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"saveArticleComment"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//文章点赞
+ (void)addArticleLike:(NSDictionary *)params
         WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"saveArticlePraise"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//取消文章点赞
+ (void)cancelArticleLike:(NSDictionary *)params
             WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"cancelArticleLike.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//评论点赞
+ (void)addCommentLike:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"addCommentLike.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//取消评论点赞
+ (void)cancelCommentLike:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"cancelCommentLike.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//文章收藏
+ (void)addArticleCollect:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"saveArticleCollect.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//取消文章收藏18
+ (void)cancelArticleCollect:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"cancelCollect.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//获取个人文章收藏
+ (void)findArticleCollect:(NSDictionary *)params
                 WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getCollectListByUserId.service"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

#pragma mark - Channels
//获取频道分类
+ (void)findChannelCategoryList:(NSDictionary *)params
              WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getChanelCatagoryList.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}
//查询频道列表接口
+ (void)findChannelList:(NSDictionary *)params
              WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getChanelList.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//根据名称搜索频道列表
+ (void)getChanelListByName:(NSDictionary *)params
                  WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"getChanelList.service"
                                  parameters:params
                                     success:^(AFHTTPRequestOperation *operation ,id JSON){
                                         if (block) block(JSON,nil);
                                     }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                         if (block) block(nil,error);
                                     }];
}

//删除评论
+ (void)deletelArticlecomment:(NSDictionary *)params
                    WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"deleteArticleComment.service"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

////获取默认搜索
//+ (void)findChannelList:(NSDictionary *)params
//              WithBlock:(void (^)(id result, NSError *error))block
//{
//    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
//    [[ServiceAPIClient sharedClient] postPath:@"getChanelList.service"
//                                   parameters:params
//                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
//                                          if (block) block(JSON,nil);
//                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
//                                          if (block) block(nil,error);
//                                      }];
//}


#pragma mark - User Center

+ (void)saveUploadFile:(NSData *)fileData
              fileName:(NSString *)fileName
            WithParams:(NSDictionary *)params
            uploadPath:(NSString *)path
              WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] uploadPath:path
                                     parameters:params
                                       fileName:fileName fileData:fileData
                                        success:^(AFHTTPRequestOperation *operation, id JSON) {
                                            if (block) block(JSON,nil);
                                        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                            if (block) block(nil,error);
                                        }];
}

//人员登录
+ (void)loginWithParams:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"userLogin.service"
                                   parameters:params
                               success:^(AFHTTPRequestOperation *operation ,id JSON){
                                   if (block) block(JSON,nil);
                               }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                   if (block) block(nil,error);
                               }];
}

//人员登出
+ (void)logoutWithParams:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"/mobile/index.php?act=logout&op=index"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

//检测注册账号
+ (void)checkUser:(NSDictionary *)params
        WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"appuser/checkuser"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

//人员注册
+ (void)registerWithParams:(NSDictionary *)params
                WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"addCustomer.service"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

//修改密码
+ (void)modifyPwd:(NSDictionary *)params
        WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"appuser/update_pas"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}


//修改昵称
+ (void)modifyNickName:(NSDictionary *)params
             WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"updateCustomerById.service"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}


//修改个人资料
+ (void)modifyUserInfo:(NSDictionary *)params
             WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"/app/aiya/api/cust/profile.do"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

//根据经纬度获取地址
+ (void)getAddress:(NSDictionary *)params
        WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"area/getaddress"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

//意见反馈
+ (void)feedBack:(NSDictionary *)params
       WithBlock:(void (^)(id result, NSError *error))block
{
    [[ServiceAPIClient sharedClient] setParameterEncoding:AFFormURLParameterEncoding];
    [[ServiceAPIClient sharedClient] postPath:@"addOpinionInfo"
                                   parameters:params
                                      success:^(AFHTTPRequestOperation *operation ,id JSON){
                                          if (block) block(JSON,nil);
                                      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
                                          if (block) block(nil,error);
                                      }];
}

@end
